using System.Web.Mvc;
using NHibernate;
using Web.Extensions;
using Web.Model;

namespace Web.Controllers
{
	public class LayoutController : Controller
	{
		[AcceptVerbs(HttpVerbs.Get | HttpVerbs.Head)]
		public ActionResult Header()
		{
            ViewBag.IdeasCount = 0;
            if (userSession.IsAuthenticated && userSession.CurrentUser.IsAdmin)
            {
                var ideas = session.CreateCriteria<Idea>().List<Idea>();
                ViewBag.IdeasCount = ideas.Count;
            }
			return View("LayoutHeader", userSession.IsAuthenticated ? userSession.CurrentUser : null);
		}

        public LayoutController(ISession session, IUserSession userSession)
		{
			this.userSession = userSession;
            this.session = session;
		}

        private readonly ISession session;
		private readonly IUserSession userSession;
	}
}